When selling short a stock, you are betting a stock will go lower, just as similarly you are betting a stock to go higher when you buy.
Technically, you are borrowing somebody elses shares (most investors keep their shares with their particular brokerage firm) and you then "sell them short". When you decided to end the position, you then buy the shares from the open market and the formerly shorted shares are then for booking purposes placed back into the investors account.
If you sell a stock short and the price goes lower, you keep the proceeds.
If you sell a stock short and the price goes higher, you owe the difference.